package com.xlh.dto.user;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.collect.Lists;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

import java.util.List;

/**
 * 下拉中的班级
 * <p>
 * Created by lx on 2019/1/28.
 */
@Data
public class ClassDTO {

    @ApiModelProperty(value = "id")
    private Long id;

    @ApiModelProperty(value = "名称")
    private String name;

    @ApiModelProperty(value = "年级")
    private String grade;

    @ApiModelProperty(value = "是否是默认 true：是  false：不是")
    private Boolean defaultedClass = false;

    @JsonIgnore
    @ApiModelProperty(value = "是否已结课 true：是  false：不是")
    private Boolean ended;

    @ApiModelProperty(value = "班级id结果集")
    private List<Long> classIds;

    @ApiModelProperty(value = "班级人数")
    private Long stuNum;
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;

        if (o == null || getClass() != o.getClass()) return false;

        ClassDTO that = (ClassDTO) o;

        return new EqualsBuilder()
                .append(id, that.id)
                .isEquals();
    }

    @Override
    public int hashCode() {
        return new HashCodeBuilder(17, 37)
                .append(id)
                .toHashCode();
    }

    public List<Long> getClassIds() {
        return id == null ? null : Lists.newArrayList(id);
    }
}
